<template>
    <h1>判断奇数偶数</h1>

    <h4>num 的值为 {{ num }}，它的值为 {{ comMsg }}</h4>

    <button @click="setNum">修改num的值</button>
</template>

<script>
export default {
    data() {
        return {
            num: 1,
            msg: '奇数'
        };
    },
    methods: {
        setNum () {
            this.num = Math.floor(Math.random() * 2)
            // this.setMsg()
        },
        setMsg () {
            console.log(1);
            this.msg = this.num ? '奇数' : '偶数'
        }
    },
    computed: {
        comMsg() {
            return this.msg = this.num ? '奇数' : '偶数'
        }
    }
    
};
</script>

<style></style>
